package com.tadpole.music.holder.question;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;
import com.tadpole.music.R;
import com.tadpole.music.holder.base.BaseViewHolder;
import java.util.List;

/**
 * Created By 孙岩
 * on 2020/9/29
 */
public class DaAnViewHolder extends BaseViewHolder {
    private View itemView;
    private List<String> list;
    private List<String> extraList;
    private TextView tvName;
    private Activity activity;

    public DaAnViewHolder(Activity activity, View itemView, List<String> list, List<String> extraList) {
        super(itemView);
        this.activity = activity;
        this.itemView = itemView;
        this.list = list;
        this.extraList = extraList;
    }

    @Override
    public void init(int position) {
        tvName = itemView.findViewById(R.id.tvName);

        if (list.size() - 1 >= position) {
            if ((Double.parseDouble(extraList.get(position)) + Double.parseDouble(extraList.get(position)) * 0.2) >= Double.parseDouble(list.get(position))
                    && (Double.parseDouble(extraList.get(position)) - Double.parseDouble(extraList.get(position)) * 0.2) <= Double.parseDouble(list.get(position))) {
                tvName.setText("对");
                tvName.setTextColor(activity.getResources().getColor(R.color.colorMain));
            } else {
                tvName.setText("错");
                tvName.setTextColor(activity.getResources().getColor(R.color.color_red));
            }
        } else {
            tvName.setText("错");
            tvName.setTextColor(activity.getResources().getColor(R.color.color_red));
        }


    }
}
